#include <bits\stdc++.h>
using namespace std;

class Solution {
public:
    int findNumberOfLIS(vector<int>& nums) {
        int n = nums.size();
        vector<int> dp(n, 1);
        vector<int> count(n, 1);
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    if (dp[j] + 1 > dp[i]) {
                        dp[i] = dp[j] + 1;
                        count[i] = count[j];
                    }
                    else if (dp[i] == dp[j] + 1)
                        count[i] += count[j];
                }
            }
        }
        int target = *max_element(dp.begin(), dp.end());
        int ret = 0;
        for (int k = 0; k < n; k++) {
            if (target == dp[k]) ret += count[k];
        }

        return ret;
    }
};